package com.sanben.project.service.impl;

import com.sanben.project.entity.ProjectRelease;
import com.sanben.project.mapper.ProjectReleaseMapper;
import com.sanben.project.service.IProjectReleaseService;
import com.sanben.project.data.dto.ProjectReleaseDto;
import com.sanben.project.data.vo.ProjectReleaseVo;
import com.sanben.project.data.req.ProjectReleaseReq;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sanben.common.util.BeanCopyUtils;

import java.util.List;

/**
 * @author cyh
 * @description: 项目发布表 服务实现类
 * @date: 2020-08-11
 */
@Service
public class ProjectReleaseServiceImpl extends ServiceImpl<ProjectReleaseMapper, ProjectRelease> implements IProjectReleaseService {

    @Override
    public IPage<ProjectReleaseVo> page(ProjectReleaseReq req) {
        Page<ProjectReleaseVo> page = new Page<>(req.getPageNum(), req.getPageSize());
        page.setRecords(this.baseMapper.page(page, req));
        return page;
    }

    @Override
    public List<ProjectReleaseVo> getHomeList() {
        List<ProjectReleaseVo> list = baseMapper.getHomeList();
        return list;
    }

    @Override
    public Boolean save(ProjectReleaseDto dto) {
        return this.save(BeanCopyUtils.copy(dto, ProjectRelease.class));
    }

    @Override
    public Boolean updateById(ProjectReleaseDto dto) {
        return this.updateById(BeanCopyUtils.copy(dto, ProjectRelease.class));
    }


    @Override
    public Boolean deleteLogic(List<Integer> toIntList) {
        return this.removeByIds(toIntList);
    }

    @Override
    public ProjectRelease detail(Integer id) {
        return this.getById(id);
    }
}
